window.onload=function (){
    findAll()
}
function findAll(){
    axios.get("class/findAll").then(resp=>{
     let info=resp.data
        console.log(info)
        if (info === "noland"){
            location.href="/index.html?errorInfo=noland";
        }
        let str = ""
        info.forEach(n=>{
            str+=`<tr><td>${n.nameClass}</td><td>${n.date}</td><td>${n.teacher}</td><td><input type="button" value="删除班级" onclick="del(${n.id})"class="button12"/></td></tr>`
        })
        $("data").innerHTML=str;
    })
}
function add(){
    $("addClass").style.visibility="visible";
}
function addClass(){
    axios.get("class/addClass",{
        params:{
            nameClass:$("className").value,
            date:$("classDay").value,
            teacher:$("classTeacher").value
        }
    }).then(rsep=>{
       var info=rsep.data
        if (info=="ok"){
            $("addClass").style.visibility="hidden";
            findAll()
        }
    })
}
function del(id) {
    axios.get("class/del",{
        params: {
            id:id
        }
    }).then(resp=>{
     var info=resp.data
        if (info==true){
            findAll()
        }else {
          $("del").style.visibility="visible";
        }
    })
}
function sure(){
    $("del").style.visibility="hidden";
}
function cancel(){
    $("addClass").style.visibility="hidden";
}